	
<?php 
	//include "../../../lib/config.php";
	//include "header.php";
	
	$maincontent = "";
	$typename =constant("MENU_SEARCH_RESULT");
	$pager = new Pager;
	if(isset($_SESSION['keyword']) )
	{
		$cFilter = new CFilter;
		$keyWord = $cFilter-> filter($_SESSION['keyword']);
		
		if($keyWord !="")
		{
			//$cType = new CType ;
			//$cCategory = new CCategory;
			$cItems = new CItems;
			
			$arrItems = $cItems->CItemsSearchResult ($keyWord);
			
			$numOfRecord = count ($arrItems);
			
			$start = $pager->findStart($pager_limit);
			$end = min($numOfRecord , $start + $pager_limit);
			
			$pages = $pager->findPages($numOfRecord , $pager_limit);
			if(!isset ($_GET['page']))
			{
				$_GET['page'] = 1; 
			}	
				
			$pagelist = $pager->PageList($_GET['page'], $pages);
			
			$curResult = $_GET['page']* $pager_limit;
			
			if(is_array($arrItems))
			{
				$maincontent .='<table bgcolor="#FFFFFF" width="100%" style="border-collapse:collapse">';
				for($i=$start; $i<$end; $i++)
				{
					$maincontent .='<tr height="72px" valign="middle" style="border-bottom:1px #AAA solid;">';
					
						$maincontent .='<td width="72" style="padding:4px;">';
						$maincontent .='<a href="products.php?jmp=idb'.$arrItems[$i]['id'].'&to='.$arrItems[$i]['name'].'&with=detail"><img class="DLThumbs" src="./applications/resources/'.$arrItems[$i]['picture'].'"> </a>';
						$maincontent .='</td>';
						$maincontent .='<td>';
						$maincontent .='<a href="products.php?jmp=idb'.$arrItems[$i]['id'].'&to='.$arrItems[$i]['name'].'&with=detail">'.$arrItems[$i]['name'].' </a>';
						$maincontent .='<br/><font color="#0072d3" size="2">ID: '.$arrItems[$i]["id_items"].'</font>';
						$maincontent .='</td>';
					
					$maincontent .='</tr>';
				}
				
				if($pages>1)		
				{
					{
						$maincontent .="<tr height='72'><td align='right' colspan='2'>". $pagelist. "</td></tr></table>";
					}
				}
				else
					$maincontent .="</table>";
			}
			else
			{
				$maincontent="There are no result for this searching...";
			}

		}
	}
	else
	{
		echo '<script language="javascript">window.location.href="index.php"</script>';
		return;		
	}
	
	//echo $maincontent ;
?>
